#include "stdafx.h"
#include "input_controller.h"
#include "config.h"


input_controller& input_controller::GetInstance()
{
	static input_controller instance;
	return instance;
}

input_controller::input_controller()
{
}

input_controller::~input_controller()
{
}

void input_controller::update(float delta_time)
{
	float delta_horizontal	= delta_time * MOVE_SPEED_H;
	float delta_vertical	= delta_time * MOVE_SPEED_V;
	float delta_rotate		= delta_time * MOVE_ROTATE;
	
	if (key_up)
		move_r += delta_rotate;
	if (key_down)
		move_x += delta_vertical;
	if (key_left)
		move_y -= delta_horizontal;
	if (key_right)
		move_y += delta_horizontal;
}

void input_controller::on_key_event(unsigned char key, bool is_pressed)
{
	switch (key)
	{
	case VK_UP:
		key_up = is_pressed;
		break;
	case VK_DOWN:
		key_down = is_pressed;
		break;
	case VK_LEFT:
		key_left = is_pressed;
		break;
	case VK_RIGHT:
		key_right = is_pressed;
		break;
	}
}
